neutron-compute-pkg:
  pkg.installed:
    - names:
      - openstack-neutron
      - openstack-neutron-linuxbridge
      - ebtables

neutron-compute-neutron-conf:
  file.managed:
    - name: /etc/neutron/neutron.conf
    - source: salt://openstack/queen/neutron-compute/files/neutron.conf
    - user: root
    - group: neutron
    - mode: 640
    - template: jinja
    - defaults:
      RABBITMQ_OPENSTACK_USER: {{ pillar['rabbitmq']['RABBITMQ_OPENSTACK_USER'] }}
      RABBITMQ_OPENSTACK_PASS: {{ pillar['rabbitmq']['RABBITMQ_OPENSTACK_PASS'] }}
      RABBITMQ_IP: {{ pillar['rabbitmq']['RABBITMQ_IP'] }}
      MEMCACHED_IP: {{ pillar['memcached']['MEMCACHED_IP'] }}
      KEYSTONE_IP: {{ pillar['keystone']['KEYSTONE_IP'] }}
      NEUTRON_KEYSTONE_USER: {{ pillar['neutron']['NEUTRON_KEYSTONE_USER'] }}
      NEUTRON_KEYSTONE_PASS: {{ pillar['neutron']['NEUTRON_KEYSTONE_PASS'] }}
    - require:
      - pkg: neutron-compute-pkg


neutron-compute-linuxbridge-conf:
  file.managed:
    - name: /etc/neutron/plugins/ml2/linuxbridge_agent.ini
    - source: salt://openstack/queen/neutron-compute/files/linuxbridge_agent.ini
    - user: root
    - group: neutron
    - mode: 640
    - require:
      - pkg: neutron-compute-pkg

neutron-compute-fix-tornado:
  file.managed:
    - name: /usr/lib/python2.7/site-packages/tenacity/__init__.py
    - source: salt://openstack/queen/neutron-compute/files/__init__.py
    - user: root
    - group: root
    - mode: 644
    - require:
      - pkg: neutron-compute-pkg

neutron-linuxbridge-agent-service:
  service.running:
    - name: neutron-linuxbridge-agent
    - enable: True
    - require:
      - file: neutron-compute-neutron-conf
      - file: neutron-compute-linuxbridge-conf
      - file: neutron-compute-fix-tornado
    - watch:
      - file: neutron-compute-linuxbridge-conf
      - file: neutron-compute-neutron-conf
